package com.suxii.widget;

import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.view.Window;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

public class NoBar {
    public static void setNoBar(Activity activity){
        activity.requestWindowFeature(Window.FEATURE_NO_TITLE);//初始化窗口为无标题栏的
        //设置状态栏和导航栏颜色为透明
        View decorView = activity.getWindow().getDecorView();
        int option = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(option);
        //设置导航栏颜色为透明
        activity.getWindow().setNavigationBarColor(Color.TRANSPARENT);
        //设置通知栏颜色为透明
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
        //隐藏导航栏
        ActionBar actionBar = ((AppCompatActivity) (activity)).getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
    }
}
